//
//  OosVideo.m
//  Oos4ios
//
//  Created by Pablo Gonzalez on 4/4/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import <oos4ios/Model/OosVideo.h>

@implementation OosVideo

static NSString *identifierPredicate = @"identifier = %@";

+ (OosVideo *) videoFromIdentifier:(NSString *)identifier
{
    
    OosVideo *result = [super objectWithPredicate: identifierPredicate, identifier];
    
    if (!result) {
        result = [super create];
        result.identifier = identifier;
    }
	return result;
}

@dynamic snapshotUrlString;

- (NSURL *)snapshotUrl
{
    NSString *url = [self snapshotUrlString];
    if (url) {
        return [NSURL URLWithString:url];
    } else {
        return nil;
    }
}

- (void)setSnapshotUrl:(NSURL *)url
{
    if (!url) {
        self.snapshotUrlString = nil;
    } else {
        self.snapshotUrlString = url.absoluteString;
    }
}

@end
